package com.cf.base.leak.observe;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cf.base.leak.ObjectWatcher;
import com.cf.base.leak.callback.ActivityLifecycleCallbacks;

/**
 * @author yangji
 */
public class ActivityLeak extends ActivityLifecycleCallbacks {
    public static void install(Application application, ObjectWatcher watcher) {
        application
                .registerActivityLifecycleCallbacks(
                        new ActivityLifecycleCallbacks() {
                            @Override
                            public void onActivityDestroyed(@NonNull Activity activity) {
                                watcher.addWatcher(activity);
                            }
                        }
                );
    }
}
